import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'

export default defineConfig({
    plugins: [vue()],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src',
                import.meta.url))
        }
    },
    optimizeDeps: {
        include: ['vue', 'vue-router']
    },
    server: {
        port: 3000,
        open: true,
        proxy: {
            // 统一代理所有微服务请求到后端服务器
            '^/(auth-mbs|wechat-mbs|user-mbs|admin-mbs|api)/.*': {
                target: 'http://127.0.0.1:9001',
                changeOrigin: true,
                rewrite: (path) => path
            }
        }
    },
    build: {
        outDir: 'dist',
        assetsDir: 'assets',
        rollupOptions: {
            input: {
                main: fileURLToPath(new URL('./index.html',
                    import.meta.url))
            }
        }
    }
})